<%-- 
    Document   : resultPage
    Created on : 2016-9-23, 9:49:06
    Author     : 52461
--%>

<%@page import="com.cxhd.pacs.DataConfig"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
         <title><%=DataConfig.getInstance().getConfig().get("systemName")%></title>
        <link rel="icon" href="${base}/favicon.ico" type="image/x-icon">
        <link href="${base}/css/bootstrap-paper.css" rel="stylesheet">
        <link href="${base}/css/font-awesome.css" rel="stylesheet">
        <link href="${base}/css/datepicker3.css" rel="stylesheet">

        <script type="text/javascript" src="${base}/js/jquery-1.9.1.js"></script>
        <script type="text/javascript" src="${base}/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="${base}/js/angular/angular.min.js"></script>
        <script type="text/javascript" src="${base}/js/jquery.cxhd.js"></script>
        <script type="text/javascript" src="${base}/js/bootstrap-datepicker.js"></script>
        <script type="text/javascript" src="${base}/js/bootstrap-datepicker.zh-CN.js"></script>
        <script src="${base}/js/angular/ui-bootstrap-tpls-0.12.0.min.js"></script>
    </head>
    <body ng-app="result" ng-controller="main" style="overflow: hidden">
        <div id="myRpt" style="overflow: auto">
            <div ng-if="item.result_type == 'image'" id="mod2"  class="mod-2" style="width: 100%">

                <img  ng-repeat="rimage in resultImages" ng-click="selectOneImage('image' + $index)" style="display: block;max-width: 100%;margin-left: auto;margin-right: auto;max-height: 100%" id="image{{$index}}" ng-src="{{rimage}}" alt="">

            </div>
            <div ng-if="item.result_type == 'text'" id="mod1" class="mod-1" style="font-size: 18px;overflow: auto">
                <table class="table">
                    <tr ng-repeat="re in results">
                        <td>{{re}}</td>
                    </tr>
                </table>

            </div>
            <div  ng-if="item.result_type == 'table' && item.data_type == 'lis_detail'" id="mod3"  class="mod-3" style="min-width: 400px;font-size: 12px;overflow: auto">
                <table width="100%" style="border-spacing:0px">
                    <tr>
                        <td colspan="5" align="right" >时间：{{lisResults[0].date_test}}</td>
                    </tr>
                    <tr class="xl_head">
                        <th align="center">简称</th>
                        <th align="center">检验项目</th>
                        <th align="center">结果</th>
                        <th align="center">参考范围</th>
                        <th align="center">单位</th>
                    </tr>
                    <tr ng-repeat="re in lisResults">
                        <td align="center">{{re.item_code}}</td>
                        <td align="center">{{re.item_name}}</td>
                        <td align="center">{{re.test_value}}&nbsp;{{re.text_node}}</td>
                        <td align="center">{{re.text_range}}</td>
                        <td align="center">{{re.text_danwei}}</td>
                    </tr>
                </table>

            </div>

            <div ng-if="item.result_type == 'html'" id="mod4"  class="mod-4" style="overflow-x: hidden;overflow-y: auto">


            </div>
            <!--<iframe ng-if="item.result_type == 'pdf'" id="mod5" ng-src="{{pdfSrc}}" frameBorder=0 scrolling=auto width="100%" height="100%"  class="mod-5"   style="overflow-x: hidden;overflow-y: auto">-->

                <div ng-if="item.result_type == 'pdf'" id="mod5"  class="mod-5" style="width: 100%">

                <img  ng-repeat="rimage in pdfImages"  style="display: block;max-width: 100%;margin-left: auto;margin-right: auto;max-height: 100%" id="image{{$index}}" src="getPdfImage?path={{rimage}}" alt="">

            </div>
            <!--</iframe>-->
            <video ng-if="item.result_type == 'video'" id="mod6" width="100%" controls=""  ng-src="{{videoSrc}}"></video>
        </div>
    </body>
</html>
<script>

    angular.module('result', [])
            .controller('main', function ($scope) {
                var result_pk = "<%= request.getAttribute("result_pk")%>";
                $.post("getResultItem", {result_pk: result_pk}, function (data) {


                    $scope.item = data;
                    var item = data;

                    $scope.showTitle = item.event_name;
                    if (item.result_type == "image") {

                        $scope.imageDetailStatus = true;
                        $scope.showId = "mod2";

                        $scope.resultImages = item.event_result.split(",");
                        for (var i in $scope.resultImages) {
                            $scope.resultImages[i] = "getImage?fileId=" + $scope.resultImages[i];
                        }
                        $scope.$apply();
                        console.log($scope.resultImages);

                    } else if (item.result_type == "pdf") {
                        $.post("getPdfToImage",{fileId:item.event_result},function(data){
                            $scope.pdfImages = data;
                             $scope.$apply();
                        })
//                        $scope.pdfSrc = 'getPdf?fileId=' + item.event_result;
//                        console.log("getPdf?fileId=" + item.event_result);
                       
                    } else if (item.result_type == "video") {

                        $scope.videoSrc = 'getVideo?fileId=' + item.event_result;
                        $scope.$apply();
                    } else if (item.result_type == 'table') {
                        $scope.imageDetailStatus = false;
                        if (item.data_type == 'lis_detail') {

                            $scope.showId = "mod3";

                            $.post("getLisResult", {pk: item.pk}, function (data) {

                                if (data) {
                                    $scope.lisResults = data;
                                    $scope.$apply();
                                }
                            })
                        }

                    } else {
                        $scope.imageDetailStatus = false;
                        $.post("getResult", {pk: item.pk, type: item.result_type,fileId: item.event_result}, function (data) {

                            if (data) {                                
                                if (item.result_type == 'html') {

                                $scope.$apply();
                                    $scope.showId = "mod4";
                                    console.log("--------------------" + $("#mod4").length);
                                    $(".mod-4").html(unescape(data));
                                    setTimeout(function () {

                                        $(".series_institution").parent().prependTo($("#paper"));
                                    }, 500);
                                } else {

                                    $scope.showId = "mod1";

                                    $scope.results = data.split("@");
                                     $scope.$apply();

                                }
                               
                            }
                        })
                    }
                })


            })


    function autoHeight() {
        var bHeight = $(window).height();

        $("#myRpt").height(bHeight);

    }
    autoHeight();

    $(document).keydown(function (event) {

        if (event.keyCode == 27) {
            // $(".showDetail").hide();
            $(".modal").modal("hide");
        }
    });

    $(window).resize(function () {
        autoHeight();
    });
</script>
